import java.io.*;
import java.net.*;
import java.util.*;
import java.security.Security;
import java.security.Provider;
import javax.net.ssl.*;

public class GetHtml {    

    private static String input = new String();
    private static Vector vInput= new Vector(10);
    private static Vector vOut = new Vector(10);

    public static void main(String[] args) {
	String url = null;
	if(args.length > 0) {
	    url = args[0];
	}
	else {
	    System.out.println("[GetHtml][URL]");
	    System.exit(0);
	}

	GetHtml myGetHtml = new GetHtml();
	myGetHtml.connectToUrl(url);
	vInput = myGetHtml.putInVectorByLine(input);
	myGetHtml.printVector(vInput);
    }

    private Vector putInVectorByLine (String input) {

	Vector v = new Vector (10);
	String element = "";
	StringTokenizer tokens = new StringTokenizer(input, "\n");
	while (tokens.hasMoreTokens()) {
	    element = tokens.nextToken();
	    if (element != null) {
		v.addElement(element);
	    }
	}
	
	return v;
    }


    private void printVector( Vector inputV) {

	Enumeration penum = inputV.elements();
	while ( penum.hasMoreElements() ) {   
	   System.out.println(penum.nextElement()+"\n");
	}
    }

  

    private void connectToUrl (String urlAddress) {
        URL url = null;        
	HttpURLConnection httpConnection = null;

	try {            

	    url = new URL (urlAddress);  

	    try {                
		httpConnection = (HttpURLConnection)url.openConnection();                
                
		httpConnection.connect();                

		// get the HTTPS server's response code                
		System.out.println("Connection Code and Message:" + 
				   httpConnection.getResponseCode() + 
				   " - " + httpConnection.getResponseMessage()+"\n");
                
		BufferedReader in = new BufferedReader(new InputStreamReader
		    (httpConnection.getInputStream()));

		StringBuffer buff1= new StringBuffer("");

		input = in.readLine();

		while (input != null) {
		    buff1.append(input);
		    input = in.readLine();
		}

		in.close();            

		input =  buff1.toString();

	    } catch (IOException ioe) {                
		System.out.println(ioe.getMessage());  
		System.exit(1);            
	    }        
	} catch (MalformedURLException mue) {            
	    System.out.println(mue.getMessage());            
	    System.exit(1);        
	} catch (Exception e) {            
	    e.printStackTrace();            
	    System.exit(1);        
	}    
    }
}






